package com.arron.simplefactory.pizzastore.improve;

import com.arron.simplefactory.pizzastore.*;

public class SimpleFactory {
    public Pizza createPizza(String type){
        Pizza pizza = null;
        if(type.equalsIgnoreCase("greek")) {
            pizza = new GreekPizza();
        }
        if(type.equalsIgnoreCase("cheese")) {
            pizza = new CheesePizza();
        }
        if(type.equalsIgnoreCase("pepper")) {
            pizza = new PepperPizza();
        }
        if(type.equalsIgnoreCase("china")) {
            pizza = new ChinaPizza();
        }
        return pizza;
    }

    /**
     *  静态工厂方法
     * @param type
     * @return
     */
    public static Pizza createPizza2(String type){
        Pizza pizza = null;
        if(type.equalsIgnoreCase("greek")) {
            pizza = new GreekPizza();
        }
        if(type.equalsIgnoreCase("cheese")) {
            pizza = new CheesePizza();
        }
        if(type.equalsIgnoreCase("pepper")) {
            pizza = new PepperPizza();
        }
        if(type.equalsIgnoreCase("china")) {
            pizza = new ChinaPizza();
        }
        return pizza;
    }
}
